<?php
namespace app\admin\controller;

use app\common\model\Idea as IdeaModel;
/**
 * 建议控制器
 * Class Idea
 * @package app\index\controller
 */
class Idea extends Base
{
    /**
     * [getIndex  查看]
     * @param
     * @return mixed|\think\response\Json
     * @author [C。]
     */
    public function getIndex()
    {
        $data = input('param.');
        $this->getPageAndSize($data);
        $model = new IdeaModel();
        $map = [];
        $user = $this->user;
        try{
            $count = $model->getCount($map);//满足条件的总数
            $allpage = intval(ceil($count / $this->size));//总页数
            $lists = $model->getlist($map,$this->from, $this->size);
            foreach($lists as &$v){
                $v['addtime'] = date('Y-m-d H:i:s',$v['addtime']);
                $http = substr($v['mimg'],0,4);
                if($http != 'http'){
                    $v['mimg'] = config('domain_name').$v['mimg'];
                }
            }
        }catch(\Exception $e){
            return admin_json(-1, '获取失败'.$e->getMessage());
        }
        writelog('查看反馈',1,$user);
        return admin_json(1,'获取成功',[
            'count' => $count,//总记录数
            'allpage' => $allpage,  //总页数
            'lists' => $lists,  //列表数据
        ]);
    }
}